﻿using Autofac;
using System.Reflection;

namespace Rbac.API
{
	/// <summary>
	/// Autofac注册服务类
	/// </summary>
	public class AutofacModuleRegister : Autofac.Module
    {
		protected override void Load(ContainerBuilder builder)
		{
			// 批量注册服务
			builder.RegisterAssemblyTypes(Assembly.Load("Rbac.Server"),Assembly.Load("Rbac.Contracts"))
				.Where(a => a.Name.EndsWith("Server")).AsImplementedInterfaces();

			builder.RegisterAssemblyTypes(
			   Assembly.Load("Rbac.Domain")
		   )
		   .Where(a => a.Name.EndsWith("Repository")).AsImplementedInterfaces();

			builder.RegisterType<TokenService>();
		}
	}
}
